import sys

from PyQt6 import QtGui
from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
from PyQt6.QtCore import pyqtSignal, Qt
from matplotlib.backend_bases import MouseButton


class ClickableLabel(QLabel):
    clicked = pyqtSignal()

    def mouseReleaseEvent(self, event):
            self.clicked.emit()


class MainWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle("Clickable QLabel Example")
        self.setGeometry(100, 100, 300, 200)

        self.label = ClickableLabel(self)
        self.label.setText("Click Me")
        self.label.clicked.connect(self.onLabelClicked)

        layout = QVBoxLayout()
        layout.addWidget(self.label)
        self.setLayout(layout)

        self.show()

    def onLabelClicked(self):
        print("QLabel clicked!")


if __name__ == '__main__':
    app = QApplication(sys.argv)
    mainWindow = MainWindow()
    sys.exit(app.exec())